package com.echo.register.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.echo.register.common.result.Result;
import com.echo.register.enums.OrderStatusEnum;
import com.echo.register.model.order.OrderInfo;
import com.echo.register.order.service.OrderService;
import com.echo.register.vo.order.OrderQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: OrderController
 * @Package: com.echo.register.order.controller
 * @Description:
 * @Author 谢同学
 * @Create 2024/1/7 15:02
 * @Version 1.0
 */
@Api(tags = "订单接口")
@RestController
@RequestMapping("/admin/order/orderInfo")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @ApiOperation(value = "订单列表（条件查询带分页）")
    @GetMapping("/{page}/{limit}")
    public Result<IPage<OrderInfo>> selectPage(@PathVariable Long page,
                                               @PathVariable Long limit,
                                               OrderQueryVo orderQueryVo){
        Page<OrderInfo> pageParam = new Page<>(page, limit);
        return Result.ok(orderService.selectPage(pageParam, orderQueryVo));
    }
    @ApiOperation(value = "获取订单状态")
    @GetMapping("getStatusList")
    public Result<?> getStatusList() {
        return Result.ok(OrderStatusEnum.getStatusList());
    }

    @ApiOperation(value = "根据订单id查询订单详情")
    @GetMapping("/show/{orderId}")
    public Result<?> getOrderInfo(@PathVariable Long orderId) {
        return Result.ok(orderService.show(orderId));
    }
}
